<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>断传入的一个数值是否是质数</title>
    <script>
        var num = parseInt(prompt('请输入一个数：'));
        function getPrimeNumbers(num) {
            for (var i = 2; i <= num; i++) {
                if (num % i == 0)
                    break;
            }
            if (i == num) {
                alert('true');
            } else {
                alert('false');
            }
        }
        getPrimeNumbers(num);
    </script>
</head>

<body>

</body>

</html>